import {throttle} from 'miniprogram-licia'
Page({
  data: {
    visitorList: [],
    isEmpty: false,
    total:'0'
  },
  goPassport(ev) {
    // console.log(ev);
    wx.navigateTo({
      url: '/visitor_pkg/pages/passport/index?id='+ev.mark.id,
    })
  },
  onLoad(){
    this.params={
      current:1,
      pageSize:5
    }
    this.getVisitorList()
    this.getMoreVisitor = throttle(() => {
      if(this.data.visitorList.length<this.data.total){
        this.getVisitorList()
      }
		
    }, 100)
  },
  async getVisitorList(){
    const {code,data:{rows:visitorList,total}}=await wx.http.get('/visitor',this.params)
    if(code!==10000) wx.utils.toast()
    console.log(visitorList);
    this.setData({
      isEmpty:visitorList.length===0,
      visitorList:[...this.data.visitorList,...visitorList],
      total
    })
    if(this.data.visitorList.length<total){
     this.params.current+=1
    }
  }
})
